/* #ifdef MP-ALIPAY */
import Fly from "flyio/dist/npm/ap";
/* #endif */
/* #ifndef MP-ALIPAY */
import Fly from "flyio/dist/npm/wx";
/* #endif */
import { $store } from "../store";
import { $config } from "../config";
import { handleError } from "./handler";

export const $http2 = new Fly();

$http2.config.baseURL = $config.api.baseUrl;
$http2.config.timeout = $config.api.timeout;
// 全局处理请求拦截
$http2.interceptors.request.use(request => {
    request.headers["Content-Language"] = $store.getters["system/locale"];
    request.headers["Content-Type"] = "application/json;charset=UTF-8";
    // request.headers["Connection"] = "keep-alive";
    // request.headers["Content-Length"] = "69";

});

// Accept: application/json, text/plain, */*
// Accept-Encoding: gzip, deflate, br
// Accept-Language: zh-CN,zh;q=0.9
// Connection: keep-alive
// Content-Length: 69
// Content-Type: application/json;charset=UTF-8
// Host: api.filscan.io:8700
// Origin: https://filscan.io
// Referer: https://filscan.io/
// Sec-Fetch-Dest: empty
// Sec-Fetch-Mode: cors
// Sec-Fetch-Site: same-site
// User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36

// 全局处理响应拦截
$http2.interceptors.response.use(response => response, handleError);
